<?
	if(isset($_POST['btnOK']))
    {
  		$error="";
       	$i=0;
		if($_POST['passwordmoi']=='')
        {
            echo "<script>alert('Vui lòng điền đầy đủ mật khẩu!!')</script>"	;
            $i=1;
        }
		if($i==0)
        {
			$email=$_SESSION['duytrinh_login_user'];
			$password=md5($_POST['password']);
			$table = "users";
			$res_mail=$t->get_by_thutu($table,-1,-1,"and email='$email' and password='$password'");
			$kq=mysql_num_rows($res_mail);
			if($kq<=0)
			{ 
				echo "<script>alert('Password này sai rồi')</script>";
			}
			else
			{
				$field = array('password');
				$values= array(format(md5($_POST["passwordmoi"]),0));
                $res = $t->updateObject($table,$field,$values,"email='$email'");
				
			 	echo "<script>alert('Đổi mật khẩu thành công!!');history.go(-1);</script>";
			}
		}
   }
?>
<div class="center">
<div class="title_center">
	<span style="float:left;margin-left:55px;">Đổi mật khẩu</span>
</div>
<div class="content_center">
<div style="width:100%;float:left;margin:10px 20px 20px 0px; text-align:left;">
<form id="form1" name="form1" method="post" action="">
<table width=440  align=center cellpadding=0 cellspacing=0 id=tbldangky style="margin-left:20px">
	
       <tr><th width="153" height="36" style="text-align:right; margin-right:20px">Mật khẩu cũ</th>
            <td width="67">&nbsp;</td>
            <td width="218"><input name="password" type="password" class="txt" id="password"/>      </td>
      </tr>	
       <tr><th width="153" height="36" style="text-align:right; margin-right:20px">Mật khẩu mới</th>
            <td width="67">&nbsp;</td>
            <td width="218"><input name="passwordmoi" type="password" class="txt" id="passwordmoi"/>      </td>
      </tr>	
        
        <tr><td colspan="3" align="center">
               <input type="submit" name="btnOK" id="btnOK" value="<? if($lang=='vi') echo 'Đổi mật khẩu'; else echo 'Submit';?>" class="btnlogin1" />
               <input type="reset" name="btnCan" id="btnCan" value="<? if($lang=='vi') echo 'Hủy'; else echo 'Cancel';?>" class="btnlogin1" />
            </td>
        </tr>
    </table>
</form>
</div>
<div class="bo_center">
</div>
</div>
 </div>
<div id="giohangan" style=" width:100%; float: left; display:none;">
 </div>
